package rule18;

import java.util.Collection;
import java.util.Set;

/**
 * @author ChangLiang
 * @date 2020/3/17
 */
public class HashSetCounterV1 {

    private Set set;

    private int count = 0;

    public HashSetCounterV1(Set set) {
        this.set = set;
    }

    public boolean add(Object object) {
        count++;
        return set.add(object);
    }

    public boolean addAll(Collection collection) {
        count += collection.size();
        return set.addAll(collection);
    }

    public int getCount() {
        return count;
    }
}
